package com.feihong.yw189.paidan.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.feihong.yw189.paidan.fragment.DispatchHome;
import com.feihong.yw189.paidan.fragment.DispatchList;
import com.feihong.yw189.paidan.fragment.DispatchWebLocation;
import com.feihong.yw189.paidan.fragment.paidan.NewOrderList;

import java.util.ArrayList;

public class DispatchAdapter extends FragmentPagerAdapter {

    private static final String[] TITLES = {"接单", "地图", "新订单", "历史订单"};
    private ArrayList<Fragment> fragments;

    public DispatchAdapter(FragmentManager fm) {
        super(fm);
        fragments = new ArrayList<>();

        DispatchHome phoneRechargeFragment = DispatchHome.newInstance(DispatchHome.class.getName());
        DispatchWebLocation mDispatchWebLocation = DispatchWebLocation.newInstance(DispatchWebLocation.class.getName());
        NewOrderList mNewOrderList = NewOrderList.newInstance(NewOrderList.class.getName());
        DispatchList gprsRechargeFragment = DispatchList.newInstance(DispatchList.class.getName());

        fragments.add(phoneRechargeFragment);
        fragments.add(mDispatchWebLocation);
        fragments.add(mNewOrderList);
        fragments.add(gprsRechargeFragment);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES[position];
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
